from fastapi import APIRouter

from app.corelibs.http_response import partner_success
from app.schemas.hrms.hrms_schemas import DepartmentSchemas
from app.services.hrms.hrms_services import DepartmentService

router = APIRouter()


@router.post('/departmentList', description="组织列表分页")
async def department_list(params: DepartmentSchemas):
    data = await DepartmentService.department_list(params)
    return partner_success(data)


@router.post('/allDepartmentList', description="组织列表不分页")
async def all_department_list(params: DepartmentSchemas):
    data = await DepartmentService.all_department_list()
    return partner_success(data)


@router.post('/departmentTree', description="组织树")
async def get_department_tree(params: DepartmentSchemas):
    data = await DepartmentService.department_tree()
    return partner_success(data)


@router.post('/departmentSave', description="保存组织")
async def save_or_update(params: DepartmentSchemas):
    data = await DepartmentService.save_or_update(params)
    return partner_success(data)


@router.post('/departmentDeleted', description="删除组织")
async def deleted(params: DepartmentSchemas):
    data = await DepartmentService.deleted(params)
    return partner_success(data)
